Skip to content

gh-156228: Use PyMem_Raw* allocators for OpenSSL in _ssl and _hashlib - #156229

Open
kumaraditya303 wants to merge 1 commit into
python:mainfrom
kumaraditya303:openssl-raw-allocators
Open

gh-156228: Use PyMem_Raw* allocators for OpenSSL in _ssl and _hashlib#156229
kumaraditya303 wants to merge 1 commit into
python:mainfrom
kumaraditya303:openssl-raw-allocators

Conversation

@kumaraditya303

@kumaraditya303 kumaraditya303 commented Aug 22, 2026

Copy link
Copy Markdown
Contributor
import tracemalloc, ssl, hashlib
tracemalloc.start()
ctx = ssl.create_default_context()      # heavy OpenSSL work
h = hashlib.new('sha3_512')             # one EVP context
traced by tracemalloc without PR with PR
ssl.create_default_context() 2.4 KB 1.27 MB
one sha3_512 context 48 B 624 B

…ashlib

Install OpenSSL memory hooks with CRYPTO_set_mem_functions() when _ssl or
_hashlib is loaded, routing OpenSSL allocations through the raw memory
allocators so they are visible to tracemalloc and custom allocators.
Installation fails benignly if another libcrypto user allocated first.
Comment thread Modules/_openssl_mem.h
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants